import api from '../../config/settings'
Page({
  data: {
    dataDict: {
      result: [{
          "id": 1,
          "name": "张铁蛋",
          "area": "#19",
          "avatar": "/images/img/b.jpg"
        },
        {
          "id": 2,
          "name": "刘亦菲",
          "area": "#19",
          "avatar": "/images/img/b.jpg"
        }
      ],
      today_count: 66
    }
  },
  refresh() {
    const that = this
    getApp().loadPageByGetRequest(api.collection, function(res){
        that.setData({
          dataDict: res.data
        })})
  },
  //页面加载好-发送请求---》发送请求方法别的地方也会有
  onLoad() {
    this.refresh()
  },
  // 下载重新加载
  onPullDownRefresh() {
    this.refresh();
  },

  // 删除这条记录
  doDeleteRow(e){
    const that = this
    var nid =e.currentTarget.dataset.nid
    getApp().deleteItem(api.collection+nid+'/', function(res){
        that.refresh()
    })
  },

  bindToForm(){
    getApp().jumpPage("form")
  },

  onShow(){
    this.refresh()
  },
  bindToStatistics(){
    getApp().jumpPage("statistics")
  }
})